﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Domain.RBAC
{
    /// <summary>
    /// 用户表
    /// 原实体名: Usermodel
    /// 修改后实体名: User (保持类名不变以兼容现有代码)
    /// </summary>
    [SugarTable("usermodel", TableDescription = "用户表")]
    public class Usermodel : BaseEntity
    {
        /// <summary>
        /// 用户编号（唯一标识）
        /// 原字段名: Usercode
        /// 修改后字段名: UserCode
        /// 用途：用于业务层面的用户唯一标识，如工号
        /// </summary>
        [SugarColumn(ColumnDescription = "用户编号", Length = 50, IsNullable = false)]
        public string UserCode { set; get; }

        /// <summary>
        /// 用户登录名/账号
        /// 原字段名: Username
        /// 修改后字段名: UserName
        /// 用途：用于登录认证的账号
        /// </summary>
        [SugarColumn(ColumnDescription = "用户名", Length = 50, IsNullable = false)]
        public string UserName { get; set; }

        /// <summary>
        /// 用户密码（加密存储）
        /// 原字段名: Userpassword
        /// 修改后字段名: Password
        /// 用途：存储加密后的用户密码
        /// xxx
        /// </summary>
        [SugarColumn(ColumnDescription = "用户密码", Length = 200, IsNullable = false)]
        public string Password { get; set; }

        /// <summary>
        /// 真实姓名
        /// 原字段名: Realname
        /// 修改后字段名: RealName
        /// </summary>
        [SugarColumn(ColumnDescription = "真实姓名", Length = 50, IsNullable = false)]
        public string RealName { get; set; }

        /// <summary>
        /// 密码加密盐值
        /// 原字段名: Salt
        /// 修改后字段名: Salt（保持不变）
        /// 用途：用于密码加密的随机盐值，提高安全性
        /// </summary>
        [SugarColumn(ColumnDescription = "加密盐值", Length = 100, IsNullable = false)]
        public string Salt { get; set; }

        /// <summary>
        /// 角色ID（外键）
        /// 原字段名: Roleid
        /// 修改后字段名: RoleId
        /// 用途：关联角色表，确定用户权限
        /// </summary>
        [SugarColumn(ColumnDescription = "角色ID", IsNullable = false)]
        public long RoleId { set; get; }

        /// <summary>
        /// 角色名称（冗余字段）
        /// 新增字段
        /// 用途：提高查询性能，避免频繁关联角色表
        /// </summary>
        [SugarColumn(ColumnDescription = "角色名称", Length = 100, IsNullable = true)]
        public string? RoleName { set; get; }

        /// <summary>
        /// 部门ID（外键）
        /// 原字段名: Departmentid
        /// 修改后字段名: DepartmentId
        /// 用途：关联部门表，确定用户所属部门
        /// </summary>
        [SugarColumn(ColumnDescription = "部门ID", IsNullable = false)]
        public long DepartmentId { get; set; }

        /// <summary>
        /// 部门名称（冗余字段）
        /// 新增字段
        /// 用途：提高查询性能，避免频繁关联部门表
        /// </summary>
        [SugarColumn(ColumnDescription = "部门名称", Length = 100, IsNullable = true)]
        public string? DepartmentName { get; set; }

        /// <summary>
        /// 手机号码
        /// 原字段名: Phone
        /// 修改后字段名: Phone（保持不变）
        /// </summary>
        [SugarColumn(ColumnDescription = "手机号码", Length = 20, IsNullable = true)]
        public string? Phone { set; get; }

        /// <summary>
        /// 电子邮箱
        /// 原字段名: Email
        /// 修改后字段名: Email（保持不变）
        /// </summary>
        [SugarColumn(ColumnDescription = "邮箱", Length = 100, IsNullable = true)]
        public string? Email { set; get; }

        /// <summary>
        /// 备注信息
        /// 新增字段
        /// 用途：记录其他需要说明的信息
        /// </summary>
        [SugarColumn(ColumnDescription = "备注", Length = 500, IsNullable = true)]
        public string? Remark { get; set; }
    }
}

